package com.peoit.honeycomb.domain.repository;

import com.peoit.honeycomb.domain.BaseEntity;

import java.util.List;

/**
 * Created by Bing.Zeng on 2015/9/23.
 */

public interface EntityRepository {

    /**
     * 新增实体
     *
     * @param entity
     *   实体
     */
    public  <T extends BaseEntity> T create(T entity);


    /**
     * 更新实体
     *
     * @param entity
     *  实体
     */
    public <T extends BaseEntity> void update(T entity);


    /**
     * 删除实体
     *
     * @param entityClass
     *            实体类
     * @param entityid
     *            实体id
     */
    public <T extends BaseEntity> void delete(Class<T> entityClass, Object entityid);

    /**
     * 根据id查询
     * @param entityClass
     * @param entityId
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> T find(Class<T> entityClass, Object entityId)  ;

    /**
     * 根据条件查询单条记录
     * @param entityClass
     * @param whereSql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity>  T queryByWhereSingle(Class<T> entityClass, String whereSql, Object[] queryParams) ;


    /**
     * 查询满足条件List
     * @param entityClass
     * @param whereSql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> List<T> queryByWhereList(Class<T> entityClass, String whereSql, Object[] queryParams) ;



    /**
     * 分页查询
     * @param entityClass
     * @param whereSql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> List<T> queryByWherePage (Class<T> entityClass, String whereSql, Object[] queryParams, int startRow, int rows);

    /**
     *
     * @param entityClass
     * @param whereSql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> boolean isExistedByWhere(Class<T> entityClass, String whereSql, Object[] queryParams)  ;

    /**
     *
     * @param entityClass
     * @param whereSql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> long getCountByWhere(Class<T> entityClass,  String whereSql, Object[] queryParams);

    /**
     *
     * @param fullJpql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> List<T> queryByFullJPQL (  String fullJpql, Object[] queryParams );

    /**
     *
     * @param fullJpql
     * @param queryParams
     * @param <T>
     * @return
     */
    public <T extends BaseEntity> Integer updateByFullJPQL(String fullJpql, Object[] queryParams);
}
